using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Markup;
using Rhizome.Contract;
using Rhizome.Contract.Diag;
using Rhizome.Contract.Visitor;
using Rhizome.Internal;

namespace Rhizome.Model
{
	/// <summary>
	/// XAML macro
	/// </summary>
	/// <typeparam name="TPlant"></typeparam>
	[ContentProperty("Actions")]
	public abstract class ActionsRuleBase<TPlant> : RuleBase<TPlant>
	{
		protected ActionsRuleBase()
		{
			Actions = new RhizomeElementCollection<IAction>(this);
		}

		public Collection<IAction> Actions { get; private set; }

		protected void ProcessActions()
		{
			Actions.ForEach(action => action.Process());
		}

		#region Overrides of RhizomeElement

		protected override IEnumerable<IEnumerable> GetElementCollections()
		{
			return base.GetElementCollections().Concat(new[] {Actions});
		}

		#endregion
	}

	public abstract class ActionsRuleBase : ActionsRuleBase<object>
	{
	}
}